<template>

  <el-dialog title="按群查找" :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="1000px">
    <div class="content-big">
      <div class="content-left">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
          <el-form-item prop="userName2">
            <el-input v-model="queryParams.input3" placeholder="输入关键字" clearable @keyup.enter.native="handleQuery" suffix-icon="el-icon-search"/>
          </el-form-item>
          <el-form-item prop="userName2">
            <el-select
              v-model="queryParams.userName6"
              @change="handleQuery"
              placeholder="全部分组"
              class="select-left"
            >
              <el-option
                v-for="item in groupList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="userName2">
            <el-select
              v-model="queryParams.userName7"
              @change="handleQuery"
              placeholder="在线状态"
              class="select-left"
            >
              <el-option
                v-for="item in labelList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div class="table-big">
          <el-button type="primary" plain style="" size="small">全选所有</el-button>
          <el-table
            :data="tableDataList"
            ref="companylabelList"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="70" align="center"/>
            <el-table-column
              :label="item.label"
              :align="item.align?item.align:``"
              v-for="(item, index) in tableColumns"
              :key="index"
              :prop="item.key"
              :min-width="item.minWidth ? item.minWidth : ``"
              :fixed="item.fixed ? item.fixed : false"
              :show-overflow-tooltip="true"
            >
              <!--用于表格自定义-->
              <template slot-scope="scope">
                <div v-if="item.key=='name'">
                  <div class="userInfo">
                    <img src="../../../assets/images/profile.jpg"/>
                    <div class="user-big">
                      <div class="name">群聊</div>
                      <div class="label">成员<span>3</span></div>
                    </div>
                  </div>

                </div>
                <div v-else style="margin-right: 20px;">{{ scope.row[item.key] }}</div>
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </div>
      </div>
      <div class="content-center">
        <div class="title">已选择（3）</div>
        <ul class="user-list">
          <li><span>肖洁</span><i class="el-icon-delete"></i></li>
          <li><span>闵雨薇</span><i class="el-icon-delete"></i></li>
        </ul>
      </div>
      <div class="content-right">
        <div class="right-title">应用记录</div>
        <ul>
          <li>
            <div class="name">民雨薇 <span>选择</span></div>
            <div class="type"><i class="round green"></i>已完成 <span>2024-01-12 14:28:03</span></div>
          </li>
          <li>
            <div class="name">民雨薇 <span>选择</span></div>
            <div class="type"><i class="round glay"></i>未完成 <span>2024-01-12 14:28:03</span></div>
          </li>
        </ul>
      </div>
    </div>


    <div class="footer-btn" slot="footer">
      <el-button @click="handleCloseDialog">取消</el-button>
      <el-button type="primary">提交</el-button>
    </div>
  </el-dialog>
</template>

<script>


import {listUser} from "@/api/system/user";
import MultipleSelect from "@/views/components/multipleSelect.vue";

export default {
  name: 'selectLabelPage',
  components: {
    MultipleSelect
  },
  data() {
    return {
      // 查询参数
      input3: null,//群查找
      radio: null,//
      labelList: [
        //称呼
        {id: 1, name: "在线"},
        {id: 2, name: "离线"},

      ],
      groupList: [
        //群查找
        {id: 1, name: "含任意关键词"},
        {id: 2, name: "含所有关键词"},
      ],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName1: null,
        userName2: null,
        userName3: null,
        userName4: null,
        userName5: null,
        userName6: null,
        userName7: null,
        userName8: null,
        userName9: null,
        userName10: null,
        userName11: null,
        userName12: null,
        userName13: null,
        userName14: null,
      },
      callList: [
        //称呼
        {id: 1, name: "有"},
        {id: 2, name: "无"},
      ],
      tableColumns: [
        {key: 'name', label: `选择本页`, visible: true, minWidth: 200, fixed: true},
        {key: 'status', label: ``, visible: true, minWidth: 150, fixed: true, align: 'right',},
      ],
      tableDataList: [],
      lableOpt: [
        {value: 1, label: '客户等级', children: [
            {value: 3, label: '核心',},
            {value: 4, label: '重要',},
            {value: 5, label: '一般',}
          ]
        },
        {value: 2, label: '客户等级2', children: [
            {value: 6, label: '可爱',},
            {value: 7, label: '知性',},
            {value: 8, label: '性感',}
          ]}
      ],
      sexList: [
        //性别
        {id: 1, name: "男"},
        {id: 2, name: "女"},
      ],
      total: 8, // 表格的总条数
      multipleSelection: [],//表格多选
      showSelectSmartTags: false,//智能标签
      tableHeight: 600,
      dateRange1: [],
    }
  },
  created() {
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: '小红',
        status: '离线',

      }
      this.tableDataList.push(obj);
    }
  },
  mounted() {
  },
  watch: {},
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(val) {
      this.multipleSelection = [];
      if (val && val.length > 0) {
        val.forEach((item) => {
          this.multipleSelection.push(item.id);
        })
        console.log('multipleSelection', this.multipleSelection);
      }
    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit('handleQuery');
    }
  }
}
</script>

<style scoped lang="scss">
.footer-btn {
  position: relative;


}

.table-big {
  position: relative;

  .el-button {
    position: absolute;
    right: 10px;
    z-index: 9;
    margin-top: 4px;
  }
}

.userInfo {
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  padding-left: 50px;
  font-size: 14px;
  list-style: none;
  text-align: left;
  display: flex;
  align-items: center;
  justify-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    left: 0px;
    top: 0px;
    position: absolute;
  }

  .label {
    margin-top: 2px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #f90;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .groupInfo {
    background-color: rgb(48, 112, 255);
    align-self: flex-start;
    width: 40px;
    padding: 2px 7px;
    display: inline-block;
    color: #fff;
    border-radius: 5px;
    margin-top: 10px;
    margin-left: 10px;

  }

  .user-big {
    display: flex;
    flex-direction: column;
    line-height: 18px;
  }
}

.content-big {
  display: flex;
  height: 100%;

  .content-left {
    width: 500px;
    background: #fff;
    border-right: 1px solid #eee;


  }

  .content-center {
    width: 176px;
    padding-top: 63px;
    border-right: 1px solid #eee;

    .title {
      background-color: #f5f5f5 !important;
      color: #2f333c;
      font-weight: 700;
      padding: 0px 20px;
      height: 43px;
      justify-content: center;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .user-list {
      margin: 0px 20px;

      li {
        display: flex;
        justify-content: space-between;
        height: 40px;
        display: flex;
        align-items: center;
      }
    }
  }

  .content-right {
    flex: 1;

    .right-title {
      height: 40px;
      line-height: 40px;
      font-weight: bold;
    }
    ul {
      li {
        display: flex;
        justify-content: space-between;
        flex-direction: column;
        background: #f7f7f7;
        margin-bottom: 10px;
        margin: 5px 15px;
        padding: 10px;
        color: rgba(0, 0, 0, .85);
        border-radius: 5px;
        .name {
          display: flex;
          justify-content: space-between;
          margin-bottom: 15px;
          span {
            color: #2d8cf0;
          }
        }
        .type {
          display: flex;
          justify-content: space-between;
          position: relative;
          padding-left: 10px;
          span {
            color: rgba(0, 0, 0, .45);
          }
          i {
            font-size: 10px;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            position: absolute;
            left: 0px;
            top: 6px;
            &.green{
              background: #52c41a;
            }
            &.glay {
              background: #c1c2c5;
            }
          }
          }
        }
      }
    }
  }


.el-form {
  padding: 0px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;

  .el-input {
    width: 150px;
    height: 32px;
    line-height: 32px;
    margin-right: 10px;
  }

  ::v-deep .el-input__inner {
    height: 32px;
    line-height: 32px;
  }

  .el-form-item {
    margin-bottom: 20px;
    margin-right: 0px;
    display: flex;


    .select-left {
      width: 132px;
      margin-right: 5px;

    }

    .select-right {
      width: 224px !important;
    }
  }

  ::v-deep .el-radio-group {
    .el-radio__input {
      display: none;
    }

    .el-radio {
      margin-right: 0px;
    }

    .el-radio__label {
      height: 32px;
      display: flex;
      justify-items: center;
      border: 1px solid #eee;
      padding: 0px 20px;
      align-items: center;
      border-radius: 5px;
    }
  }
}

::v-deep .el-dialog__body {
  overflow-y: auto;
  height: 600px;
  padding: 0px;
}

.el-checkbox-group {
  margin-top: 20px;

  .el-checkbox {
    margin-bottom: 12px;
    width: 150px;
  }
}

.title {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;

  span {
    color: #3370ff;
  }
}

</style>
